package network;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;

import main.Room;

import clientHandle.HandleFromClient;


public class HandleAcceptClient implements Runnable{
	private ServerSocket serverSocket = null;
	private ServerConnection connection = null;
	
	public HandleAcceptClient(ServerSocket serverSocket, ServerConnection connection) {
		this.serverSocket = serverSocket;
		this.connection = connection;
	}
	
	public void run() {
		try {
			while(true) {
				
				System.out.println("Waiting for clients......");
				Socket readSocket = serverSocket.accept();
				System.out.println("New client connected");
				HandleFromClient fromTask = new HandleFromClient(readSocket);
				new Thread(fromTask).start();
			}
		}
		catch(IOException ex) {
			ex.printStackTrace();
		}
	}

}
